package com.huatai.exchange.utils;


import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.huatai.exchange.integration.base.service.WorkDayService;
import com.huatai.exchange.integration.vba.service.FundInfoVoService;
import com.huatai.exchange.integration.vba.service.VbaFundNavDayService;
import com.huatai.exchange.integration.webside.service.LiquidateFlowQueryService;
import com.huatai.exchange.service.ExcDataFileInfoService;
import org.apache.velocity.VelocityContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * VelocityContext相关操作，初始化上下文的工具类和报文数据
 */
@Service
public class VelocityContextHelper {

    @Autowired
    private FundInfoVoService fundInfoVoService;

    @Autowired
    private VbaFundNavDayService VbaFundNavDayService;

    @Autowired
    private WorkDayService workDayService;

    @Autowired
    private ExcDataFileInfoService excDataFileInfoService ;

    @Autowired
    private LiquidateFlowQueryService LiquidateFlowQueryService;

    /**
     * 填充<code>VelocityContext</code>，包括业务数据对象和相关的工具类
     *
     * @param request
     * @return
     */
    public VelocityContext fillContext(Map<String, Object> request) {

        VelocityContext context = new VelocityContext();
        context.put("req", request);
        // 工具类
        context.put("fundInfoUtil", fundInfoVoService);
        context.put("fundNavUtil", VbaFundNavDayService);
        context.put("workDayUtil", workDayService);
        context.put("excDataFileInfoUtil",excDataFileInfoService) ;
        context.put("LiquidateFlowQueryUtil",LiquidateFlowQueryService) ;
        //实现模板嵌套的数据共享
        context.put("context", context);
        return context;
    }

}
